using MongoDB.Driver;
using Sustainalytics.Synchronization.Validation.Handlers.Common;
using Sustainalytics.Synchronization.Validation.Internals;
using Sustainalytics.Synchronization.Validation.Validators;
using System;
using Sustainalytics.ESG.Entities;

namespace Sustainalytics.Synchronization.Validation.Handlers.Comprehensive
{
    public class ComprehensiveRpCompanyProfileHandler : Handler<RPCompanyProfile, ComprehensiveCompanies>
    {
        public ComprehensiveRpCompanyProfileHandler(ComprehensiveCompanies comprehensiveCompanies, ValidationMongoCollection<RPCompanyProfile> collections, ComprehensiveValidator<RPCompanyProfile> validator)
            : base(comprehensiveCompanies, collections, validator)
        {
        }

        protected override ProjectionDefinition<RPCompanyProfile> GetProjectionDefinition()
        {
            return Builders<RPCompanyProfile>.Projection
                .Include(x => x.Id)
                .Include(x => x.AnalystCommentary)
                .Include(x => x.LastAnnualReportDate)
                .Include(x => x.LastFeedbackRequestDate);
        }

        protected override FilterDefinition<RPCompanyProfile> GetReferenceEntityFilter(RPCompanyProfile validatedEntity)
        {
            return Builders<RPCompanyProfile>.Filter.Where(x => x.Id == validatedEntity.Id);
        }

        protected override FilterDefinition<RPCompanyProfile> GetValidatedEntityFilterDefinition(Guid companyId)
        {
            return Builders<RPCompanyProfile>.Filter.Where(x => x.Id == companyId);
        }
    }
}
